using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace HeresyManager.Skills.SecretTongues
{
    [Serializable]
    public class SecretTongueOther : SecretTongue
    {
        public SecretTongueOther(SkillLevel level)
            : base(level)
        {
        }
        public SecretTongueOther(SkillLevel level, String other)
            : this(level)
        {
            Other = other;
        }
        public override string Name
        {
            get
            {
                return "Secret Tongue (" + Other + ")";
            }
        }


        public String Other { get; private set; }




        internal override IEnumerator<Comunication.Comunicator> Accire(Character character)
        {
            if (String.IsNullOrWhiteSpace(Other))
            {
                var com = new Comunication.EnterStringComunicator("SecretTongue");
                while (String.IsNullOrWhiteSpace(com.Answer))
                    yield return com;
                Other = com.Answer;
            }
            var en = base.Accire(character);
            while (en.MoveNext())
                yield return en.Current;
        }



        // override object.Equals
        public override bool Equals(object obj)
        {
            return base.Equals(obj) && this.Name.Equals((obj as SecretTongueOther).Name);
        }

        // override object.GetHashCode
        public override int GetHashCode()
        {
            return base.GetHashCode() * 31 + Name.GetHashCode();
        }
    }
}
